package com.hcbd.tdwt.ui.setting.xingyu.activity;

import static android.widget.Toast.makeText;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.widget.TextView;
import android.widget.Toast;


import com.hcbd.tdwt.MainApp;
import com.hcbd.tdwt.R;
import com.hcbd.tdwt.base.BaseActivity;
import com.hcbd.tdwt.base.bd.BdToolFactory;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

@SuppressLint("NonConstantResourceId")
@EActivity(R.layout.activity_about_us)
public class AboutActivity extends BaseActivity {
    @ViewById
    TextView current_version;
    public Toast mToast;

    public int index=0;
    @AfterViews
    protected void init() {
        current_version.setText(String.format("Version%s", getVersionName()));
    }


    public String getVersionName() {
        try {
            // 获取packagemanager的实例
            PackageManager packageManager = this.getPackageManager();
            // getPackageName()是你当前类的包名，0代表是获取版本信息
            PackageInfo packInfo = packageManager.getPackageInfo(this.getPackageName(), 0);
            return packInfo.versionName;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "0";
    }
    @Click
    void bgLL(){
        if(BdToolFactory.app_type==BdToolFactory.XY_PDA_BG_TYPE){
            if(index>=10){
                Intent intent=new Intent();
                intent.setClass(this, AutoTestActivity_.class);
                startActivity(intent);
            }else{
                index+=1;
                toast("在点击"+(10-index)+"次,便可开启测试界面!");
            }
        }
    }
    @Click
    void headLeft(){
        finish();
    }

    @Override
    public void toast(String tip) {
        if (null == mToast) {
            mToast = makeText(this, tip, Toast.LENGTH_SHORT);
        } else {
            mToast.cancel();
            mToast.setText(tip);
        }
        mToast.show();
    }
}
